#ifndef __COMMON_MAP_API_H_
#define __COMMON_MAP_API_H_

#include "typedef.h"
#include "queuedef.h"

typedef struct HashMap
{
    struct Queue slots[16];
} *HashMap;

typedef struct HashNode
{
    object value;
    object key;
    struct QueueNode qn;
} *HashNode;


void init_hashmap(HashMap m);

/**
 * @brief insert object with hash node
 *
 * @param m the hash map
 * @param n  the hash node
 * @param key the key to index
 * @param value the value mapped with the key
 *
 * @return boolean True if success
 */
boolean insert_object(HashMap m, HashNode n, object key, object value);

/**
 * @brief find the hash node of the object  
 *
 * @param m the hash map
 * @param obj the object
 * @return HashNode 
 */
HashNode find_object(HashMap m, object obj);

/**
 * @brief remove object from the hash map
 *
 * @param m the hash map
 * @param obj the object
 * @return boolean  True if success
 */
boolean delete_object(HashMap m, object obj);

/**
 * @brief insert object with hash node
 *
 * @param m the hash map
 * @param n  the hash node
 * @param key the key to index
 * @param value the value mapped with the key
 *
 * @return boolean True if success
 */
boolean insert_object_str(HashMap m, HashNode n, const char* key, object value);

/**
 * @brief find the hash node of the object  
 *
 * @param m the hash map
 * @param obj the object
 * @return HashNode 
 */
HashNode find_object_str(HashMap m, const char* obj);

/**
 * @brief remove object from the hash map
 *
 * @param m the hash map
 * @param obj the object
 * @return boolean  True if success
 */
boolean delete_object_str(HashMap m, const char* obj);
#endif//__COMMON_MAP_API_H_
